#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.direname(File.dirname(File.realpath($PROGRAM_NAME)))

if ENV['RESULT_ROOT']
    fn = File.join ENV['RESULT_ROOT'], 'output'
elsif ARGV[0]
    fn = ARGV[0]
end

contents = File.read(fn).split("\n")

flag = 1

contents.each do |line|
    case line
    # [INFO] Unzipping vmlinuz success!
    when /^\[INFO\] Unzipping vmlinuz success!$/
        flag = 0
        break
    end
end

puts "result: #{flag}"

if flag == 0
    result = /^\/root\/qcow2\/mnt\/(.+)\/(.+)\/(.+)$/.match(contents.last)
    puts "os.message: #{result[1]}"
    puts "arch.message: #{result[2]}"
    puts "version.message: #{result[3]}"
end
